﻿using System.Windows.Forms;
using WiimoteLib;

namespace WiimoteInterface
{
    public class WiimoteInput : Wiimote
    {
        //private Wiimote m_wiimote;

		public WiimoteInput( )
		{

		}

        public bool InitWiimote( )
        {
			try
			{
				this.Connect( );

				//this.WiimoteChanged += wm_WiimoteChanged;
				//this.WiimoteExtensionChanged += wm_WiimoteExtensionChanged;

				this.SetReportType( InputReport.IRExtensionAccel, IRSensitivity.Maximum, true );
				this.SetLEDs( true, false, false, false );
				this.InitializeMotionPlus( );
			}
			catch( WiimoteNotFoundException ex )
			{
				MessageBox.Show( ex.Message, "Wiimote not found error", MessageBoxButtons.OK, MessageBoxIcon.Error );
			}

			return true;
        }
	
		// Event Handlers
		//private void wm_WiimoteChanged( object sender, WiimoteChangedEventArgs e )
		//{
		//	WiimoteInfo wi = mWiimoteMap[ ( ( Wiimote )sender ).ID ];
		//	wi.UpdateState( e );
		//}
		//
		//private void wm_WiimoteExtensionChanged( object sender, WiimoteExtensionChangedEventArgs e )
		//{
		//	// find the control for this Wiimote
		//	WiimoteInfo wi = mWiimoteMap[ ( ( Wiimote )sender ).ID ];
		//	wi.UpdateExtension( e );
		//
		//	if( e.Inserted )
		//		( ( Wiimote )sender ).SetReportType( InputReport.IRExtensionAccel, true );
		//	else
		//		( ( Wiimote )sender ).SetReportType( InputReport.IRAccel, true );
		//}

	}
}